﻿#include "calendar.h"
#include "lvgl.h"
#include "page.h"
lv_obj_t* calendar;
lv_obj_t* calendarHeader;
void calendar_init()
{
    calendarPage.page = lv_obj_create(0);
    calendar = lv_calendar_create(calendarPage.page);
    lv_obj_set_size(calendar, 320, 200);
    lv_obj_set_pos(calendar,0,40);
    //calendarHeader = lv_calendar_header_dropdown_create(calendarPage.page, calendar);
    calendarHeader = lv_calendar_header_arrow_create(calendarPage.page,calendar,20);

    lv_calendar_set_today_date(calendar, 2021, 02, 23);
    lv_calendar_set_showed_date(calendar, 2021, 02);

    calendarPage.show = show_calendar_page;
}

void show_calendar_page()
{
    lv_group_remove_all_objs(group);
    for (int i = 0; i < lv_obj_get_child_cnt(calendarHeader);i++)
    {
        lv_obj_t* t = lv_obj_get_child(calendarHeader,i);
        if (lv_obj_has_flag(t, LV_OBJ_FLAG_CLICKABLE))
        {
            lv_group_add_obj(group, t);
        }
        
    }
    
    lv_group_add_obj(group,calendar);

    lv_scr_load(calendarPage.page);
    push_page(&calendarPage);
}
